package com.wf.controller;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.alibaba.druid.sql.visitor.SQLASTOutputVisitor;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.wf.domain.ContractInfo;
import com.wf.domain.HousesInfo;
import com.wf.dto.Apart_houses;
import com.wf.dto.Houses_facility_DTO;
import com.wf.mapper.ContractInfoMapper;
import com.wf.service.ContractInfoService;
import com.wf.service.HousesInfoService;
import com.wf.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * @Author: zhiyu
 * @Date:14:02
 * @DESC:
 */
@Api("合同控制层")
@RestController
@CrossOrigin
public class ContractController {
    @Autowired
    private ContractInfoService contractInfoService;
    @Autowired
    private ContractInfoMapper contractInfoMapper;
    @ApiOperation("动态组合查询合同付款信息")
    @GetMapping("/selectContract")
    public Result selectContract(@RequestParam(required = false,value = "status") Integer status,@RequestParam(value = "user_id",required = false) Integer user_id){
        List<ContractInfo> list = contractInfoService.selectContract(status,user_id);
        return Result.success(list);
    }
    @ApiOperation("逻辑删除合同信息")
    @PutMapping("/deleteContract")
    public Result deleteContract(Integer contract_id){
        boolean flag = false;
        int i = contractInfoMapper.deleteById(contract_id);
        if (i>0){
            flag=true;
        }
        return Result.success(flag);
    }
    @GetMapping("/selectInvoiceRequest")
    @ApiOperation("获取电子发票申请")
    public Result selectInvoiceRequest(){
        Set<HashMap<String, Object>> hashMaps = contractInfoService.selectInvoiceRequest();
        System.out.println("hashMaps = " + hashMaps);
        return Result.success(hashMaps);
    }
//    @ApiOperation("动态组合查询合同、房间以及用户信息")
//    @GetMapping("/selectConAllInfo")
//    public Result selectConAllInfo(@RequestParam(required = false) Integer contract_id){
//        Map<String, Object> map = contractInfoService.selectConAllInfo(contract_id);
//        return Result.success(map);
//    }
}
